package com.world.web.controller.wifi;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.world.common.annotation.Log;
import com.world.common.core.controller.BaseController;
import com.world.common.core.domain.AjaxResult;
import com.world.common.enums.BusinessType;
import com.world.wifi.domain.WifiFlow;
import com.world.wifi.service.IWifiFlowService;
import com.world.common.utils.poi.ExcelUtil;
import com.world.common.core.page.TableDataInfo;

/**
 * 流量Controller
 * 
 * @author LiJunXi
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/wifi/flow")
public class WifiFlowController extends BaseController
{
    @Autowired
    private IWifiFlowService wifiFlowService;

    /**
     * 查询流量列表
     */
    @PreAuthorize("@ss.hasPermi('wifi:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(WifiFlow wifiFlow)
    {
        startPage();
        List<WifiFlow> list = wifiFlowService.selectWifiFlowList(wifiFlow);
        return getDataTable(list);
    }

    /**
     * 导出流量列表
     */
    @PreAuthorize("@ss.hasPermi('wifi:flow:export')")
    @Log(title = "流量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WifiFlow wifiFlow)
    {
        List<WifiFlow> list = wifiFlowService.selectWifiFlowList(wifiFlow);
        ExcelUtil<WifiFlow> util = new ExcelUtil<WifiFlow>(WifiFlow.class);
        util.exportExcel(response, list, "流量数据");
    }

    /**
     * 获取流量详细信息
     */
    @PreAuthorize("@ss.hasPermi('wifi:flow:query')")
    @GetMapping(value = "/{flowId}")
    public AjaxResult getInfo(@PathVariable("flowId") Long flowId)
    {
        return success(wifiFlowService.selectWifiFlowByFlowId(flowId));
    }

    /**
     * 新增流量
     */
    @PreAuthorize("@ss.hasPermi('wifi:flow:add')")
    @Log(title = "流量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WifiFlow wifiFlow)
    {
        return toAjax(wifiFlowService.insertWifiFlow(wifiFlow));
    }

    /**
     * 修改流量
     */
    @PreAuthorize("@ss.hasPermi('wifi:flow:edit')")
    @Log(title = "流量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WifiFlow wifiFlow)
    {
        return toAjax(wifiFlowService.updateWifiFlow(wifiFlow));
    }

    /**
     * 删除流量
     */
    @PreAuthorize("@ss.hasPermi('wifi:flow:remove')")
    @Log(title = "流量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flowIds}")
    public AjaxResult remove(@PathVariable Long[] flowIds)
    {
        return toAjax(wifiFlowService.deleteWifiFlowByFlowIds(flowIds));
    }
}
